package com.example.springlearn.configuration;

import com.example.springlearn.interceptor.LoginEdInterceptor;
import com.example.springlearn.interceptor.UserMsgInterceptor;
import com.example.springlearn.listener.SessionListener;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserMsgInterceptor())
                .addPathPatterns("/**").excludePathPatterns("/", "/login/**", "/css/**", "/js/**", "/img/**","/font/**", "/webjars/**");
        registry.addInterceptor(new LoginEdInterceptor())
                .addPathPatterns("/", "/login/**");
        WebMvcConfigurer.super.addInterceptors(registry);
        log.info("拦截器 已加载配置");
    }

}
